import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
import zhCN from 'antd/es/locale/zh_CN';
import { ConfigProvider } from 'antd'
import { mainRouter } from './routes'
import { Provider } from 'react-redux'
import './index.less'
import store from './store'
ReactDOM.render(
   <Provider store={store}>

      <ConfigProvider locale={zhCN}>
         <Router>
            <Switch>
               <Route path='/admin' render={(routerProps) => {
                  //后期做权限处理, 需要登陆才能访问/admin
                  return store.getState().Login.isLogin? <App {...routerProps} />:<Redirect to='/login' />
               }}></Route>
               {
                  mainRouter.map((route) => {
                     return <Route key={route.pathname} path={route.pathname} component={route.component} />
                  })
               }
               <Redirect to='/admin' from='/' exact />
               <Redirect to='/404' />
            </Switch>
         </Router>
      </ConfigProvider>
   </Provider>

   ,



   document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA

